package com.paygate.entity

import com.paygate.long
import com.paygate.string
import org.ktorm.entity.Entity
import org.ktorm.schema.*
import java.time.LocalDateTime

/**
 * 交易
 */
interface Trade : Entity<Trade> {
    var id: long
    var amount: string
    var currency: string
    var status: string
    var createDate: LocalDateTime
    var cardNo: string
    var cardCvv:string
    var cardExpiredYear:string
    var cardExpiredMonth:string
    var cardHolderFirstName:string
    var cardHolderLastName:string
    var cardHolderEmail:string
    var channelStatus:string
    var channelOrderNo:string
    var channelMsg:string
    companion object : Entity.Factory<Trade>()

    object table : Table<Trade>("t_trade") {
        val id = long("id").primaryKey().bindTo { it.id }
        val createDate = datetime("create_date").bindTo { it.createDate }
        val status = varchar("status").bindTo { it.status }
        val amount = varchar("amount").bindTo { it.amount }
        val currency = varchar("currency").bindTo { it.currency }
        val cardNo = varchar("card_no").bindTo { it.cardNo }
        val cardCvv = varchar("card_cvv").bindTo { it.cardCvv }
        val cardExpiredYear = varchar("card_expired_year").bindTo { it.cardExpiredYear }
        val cardExpiredMonth = varchar("card_expired_month").bindTo { it.cardExpiredMonth }
        val cardHolderFirstName = varchar("card_holder_firstName").bindTo { it.cardHolderFirstName }
        val cardHolderLastName = varchar("card_holder_lastName").bindTo { it.cardHolderLastName }
        val cardHolderEmail = varchar("card_holder_email").bindTo { it.cardHolderEmail }
        val channelStatus = varchar("channel_status").bindTo { it.channelStatus }
        val channelMsg = varchar("channel_msg").bindTo { it.channelMsg }
        val channelOrderNo = varchar("channel_order_no").bindTo { it.channelOrderNo }
    }
}